package com.iot.web.controller.device;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iot.common.annotation.Log;
import com.iot.common.core.controller.BaseController;
import com.iot.common.core.domain.AjaxResult;
import com.iot.common.enums.BusinessType;
import com.iot.device.domain.QuakeEvent;
import com.iot.device.service.IQuakeEventService;
import com.iot.common.utils.poi.ExcelUtil;
import com.iot.common.core.page.TableDataInfo;

/**
 * 震动监测预警事件Controller
 * 
 * @author iot
 * @date 2023-04-14
 */
@RestController
@RequestMapping("/device/quakeEvent")
public class QuakeEventController extends BaseController
{
    @Autowired
    private IQuakeEventService quakeEventService;

    /**
     * 查询震动监测预警事件列表
     */
    @PreAuthorize("@ss.hasPermi('device:quakeEvent:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuakeEvent quakeEvent)
    {
        startPage();
        List<QuakeEvent> list = quakeEventService.selectQuakeEventList(quakeEvent);
        return getDataTable(list);
    }

    /**
     * 导出震动监测预警事件列表
     */
    @PreAuthorize("@ss.hasPermi('device:quakeEvent:export')")
    @Log(title = "震动监测预警事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QuakeEvent quakeEvent)
    {
        List<QuakeEvent> list = quakeEventService.selectQuakeEventList(quakeEvent);
        ExcelUtil<QuakeEvent> util = new ExcelUtil<QuakeEvent>(QuakeEvent.class);
        util.exportExcel(response, list, "震动监测预警事件数据");
    }

    /**
     * 获取震动监测预警事件详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:quakeEvent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(quakeEventService.selectQuakeEventById(id));
    }

    /**
     * 新增震动监测预警事件
     */
    @PreAuthorize("@ss.hasPermi('device:quakeEvent:add')")
    @Log(title = "震动监测预警事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuakeEvent quakeEvent)
    {
        return toAjax(quakeEventService.insertQuakeEvent(quakeEvent));
    }

    /**
     * 修改震动监测预警事件
     */
    @PreAuthorize("@ss.hasPermi('device:quakeEvent:edit')")
    @Log(title = "震动监测预警事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuakeEvent quakeEvent)
    {
        return toAjax(quakeEventService.updateQuakeEvent(quakeEvent));
    }

    /**
     * 删除震动监测预警事件
     */
    @PreAuthorize("@ss.hasPermi('device:quakeEvent:remove')")
    @Log(title = "震动监测预警事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(quakeEventService.deleteQuakeEventByIds(ids));
    }
}
